package com.action.blog.board;

import java.util.Map;

import com.db.blogboard.*;
import com.opensymphony.xwork2.ActionContext;

public class UpdateOkAction {
	private String subject;
	private String content;
	private String pwd;
	private int ono;
	private int jsptype;
	private int no;
	private BoardDAO blogboard;

	public BoardDAO getBlogboard() {
		return blogboard;
	}

	public void setBlogboard(BoardDAO blogboard) {
		this.blogboard = blogboard;
	}

	private String result;

	public int getOno() {
		return ono;
	}

	public void setOno(int ono) {
		this.ono = ono;
	}

	public int getJsptype() {
		return jsptype;
	}

	public void setJsptype(int jsptype) {
		this.jsptype = jsptype;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getResult() {
		return result;
	}

	public String bbupdate_ok() throws Exception {
		Map session = ActionContext.getContext().getSession();
		BoardVO vo = new BoardVO();

		vo.setOno(ono);
		vo.setIdtype(session.get("idtype").toString());
		vo.setNo(no);
		vo = blogboard.boardSelectContentData(vo);

		if (vo.getPwd().equals(pwd)) {

			result = "OK";

			vo.setId(session.get("login").toString());
			vo.setSubject(subject);
			vo.setContent(content);
			vo.setNo(no);
			vo.setIdtype(session.get("idtype").toString());

			System.out.println("bbupdate : " + vo.toString());
			blogboard.bbupdate(vo);

		} else {
			result = "NO";
		}

		return "success";
	}

	public String bpupdate_ok() throws Exception {

		Map session = ActionContext.getContext().getSession();
		BoardVO vo = new BoardVO();

		vo.setOno(ono);
		vo.setIdtype(session.get("idtype").toString());
		vo.setNo(no);
		vo = blogboard.boardSelectContentData(vo);

		if (vo.getPwd().equals(pwd)) {

			result = "OK";

			vo.setId(session.get("login").toString());
			vo.setSubject(subject);
			vo.setContent(content);
			vo.setNo(no);
			vo.setIdtype(session.get("idtype").toString());

			System.out.println("bpupdate : " + vo.toString());
			blogboard.bbupdate(vo);

		} else {
			result = "NO";
		}

		return "success";
	}

	public String bgupdate_ok() throws Exception {
		return "success";
	}

}
